package com.eduplatform.dto;

import lombok.Data;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.List;

@Data
public class TeacherDTO {

    private Long id;

    @NotBlank(message = "用户名不能为空")
    @Size(min = 3, max = 20, message = "用户名长度必须在3-20个字符之间")
    private String username;

    @NotBlank(message = "密码不能为空")
    @Size(min = 6, max = 20, message = "密码长度必须在6-20个字符之间")
    private String password;

    @NotBlank(message = "昵称不能为空")
    private String nickname;

    private String avatar;

    @Email(message = "邮箱格式不正确")
    private String email;

    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String phone;

    @NotNull(message = "学校ID不能为空")
    private Long schoolId;

    private String schoolName; // 用于前端展示，非提交字段

    @NotNull(message = "教育阶段不能为空")
    private Integer educationLevel; // 教育阶段：1-小学，2-初中，3-高中，4-大学

    private String educationLevelName; // 教育阶段名称（前端展示用）

    private List<Long> subjectIds; // 教师任教的学科ID列表

    private List<SubjectDTO> subjects; // 教师任教的学科列表（前端展示用）

    public String getEducationLevelName() {
        if (educationLevel == null) {
            return "";
        }
        switch (educationLevel) {
            case 1:
                return "小学";
            case 2:
                return "初中";
            case 3:
                return "高中";
            case 4:
                return "大学";
            default:
                return "";
        }
    }
}